package q278_firstBadVersion;

public class Solution {
    public int firstBadVersion(int n) {
        if (isBadVersion(1)) {
            return 1;
        }
        int left = 1, right = n;
        while (right > left) {
            int mid = left + (right - left) / 2;
            if (isBadVersion(mid)) {

                right = mid;
            }else {
                left = mid + 1;
            }
        }

        return left;
    }
    boolean isBadVersion(int version){
        return version < 4;
    }
}
